<script type="text/javascript" src="<?=BASE_URL();?>java_scripts/vote_scripts.js"></script>

<?php 
	$error_msg=(!isset($error))?"":$error;
?>
	<h3 class="capture">Vote Management</h3>
    <div id="wrap">
    
    <div id="tdd_selected">
    	<div class="dd_selected">Update - Vote Topic</div>
        <div class="dd_view">

	      	<form action="" method="post">
	      		<?php 
	      			foreach($topics->result_array() as $topic){	
		      			$id=(!isset($error))?$topic['top_id']:$top_id;
		      			$top_name=(!isset($error))?$topic['top_name']:$top_name;
		      			$top_desc=(!isset($error))?$topic['top_desc']:$top_desc;
		      			$max=(!isset($error))?$topic['top_item_max']:$max_item;
	      		?>
	      		<table border="0" cellpadding="0" cellspacing="0" width="60%" align="center">
	      			<tr><td colspan="2" height="15"> </td></tr>
	      			<tr align="center">
	      				<td height="" align="right">
	      				<input type="hidden" value="<?=$id?>" name="txttopid" id="txttopid">
	      				Topic Name :&nbsp;&nbsp;&nbsp;
	      				</td>
	      				<td align="left"><input type="text" value="<?=$top_name?>" name="txttopname" id="txttopname" maxlength="255" style="width: 350px;" /><div id='existing'><?=$error_msg?></div></td>
	      			</tr>
	      			<tr align="center">
	      				<td height="55" align="right">Category :&nbsp;&nbsp;&nbsp;</td>
	      				<td align="left">
	      					<select name="selcat" id="selcat" >
	      						<?php 
	      							foreach ($categories->result_array() as $category) {
	      								if(isset($cat_id)){
	      									$selectMe=($cat_id==$category['vote_item_cat_id'])?"selected":"";
	      								}else{
	      									$selectMe=($category['vote_item_cat_id']==$topic['vote_item_cat_id'])?"selected":"";
	      								}
	      						?>
	      						<option <?=$selectMe?> value="<?=$category['vote_item_cat_id']?>"><?=$category['vote_item_cat_desc']?></option>
	      						<?php 
	      							}
	      						?>
	      					</select>
	      				</td>
	      			</tr>
	      			<tr align="center">
	      				<td height="55" align="right">Description :&nbsp;&nbsp;&nbsp;</td>
	      				<td align="left">
	      				<textarea rows="5" name="txttopdesc" id="txttopdesc" style="width: 350px;"><?=$top_desc?></textarea>
	      				</td>
	      			</tr>
	      			<tr align="center">
	      				<td height="55" align="right">Max Item :&nbsp;&nbsp;&nbsp;</td>
	      				<td align="left"><input type="text" value="<?=$max?>" name="txtmax" id="txtmax" maxlength="3" style="width: 350px;" /></td>
	      			</tr>
	      			<tr align="center">
	      				<td>&nbsp;</td>
	      				<td height="20" colspan="2" align="left"><br/><input type="button" class="button_back_end" onclick="javascript:window.location='<?=site_url("vote_management/voteTopic")?>'" style="cursor: pointer;" value="Back"/>&nbsp;&nbsp;<input type="button" class="button_back_end" onclick="javascript:updateTopic('<?=site_url("vote_management/updateTopic")?>')" style="cursor: pointer;" value="Update"/></td>
	      			</tr>
	      		</table>
	      		<?php 
	      			}
	      		?>
	      	</form>
</div>
</div>
</div>
